class Solution(object):
    def numPoints(self, darts, r):
        max_num = 1
        n = len(darts)

        def find(x, y):
            ans = 0
            for u, v in darts:
                if (u - x) ** 2 + (v - y) ** 2 <= r ** 2:
                    ans += 1
            return ans

        for i in range(n):
            for j in range(i + 1, n):
                if darts[i] == darts[j]:
                    max_num = max(max_num, find(darts[i][0], darts[i][1]))
                else:
                    mid_x = (darts[i][0] + darts[j][0]) / 2
                    mid_y = (darts[i][1] + darts[j][1]) / 2
                    xiangliang = [darts[j][0] - darts[i][0], darts[j][1] - darts[i][1]]
                    if xiangliang[0] ** 2 + xiangliang[1] ** 2 <= (2 * r) ** 2:
                        if darts[i][1] == darts[j][1]:
                            fangxiang = [0, 1]
                        else:
                            fangxiang = [1, - xiangliang[0] / xiangliang[1]]
                            length = (fangxiang[0] ** 2 + fangxiang[1] ** 2) ** 0.5
                            fangxiang = [fangxiang[0] / length, fangxiang[1] / length]
                        h = (r ** 2 - (xiangliang[0] ** 2 + xiangliang[1] ** 2) / 4) ** 0.5
                        center_x = mid_x + fangxiang[0] * h
                        center_y = mid_y + fangxiang[1] * h
                        max_num = max(max_num, find(center_x, center_y))
                        center_x = mid_x - fangxiang[0] * h
                        center_y = mid_y - fangxiang[1] * h
                        max_num = max(max_num, find(center_x, center_y))
        return max_num


data = Solution()
darts = [[-2, 0], [2, 0], [0, 2], [0, -2]]
r = 2
print(data.numPoints(darts, r))
# darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]]
# r = 5
# print(data.numPoints(darts, r))
